home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / shaders / k3d_windywave.sl < prev    next >
Encoding:
Text File  |  2004-07-23  |  650 b   |  30 lines

  1. #define snoise(Pt) (2*noise(Pt) - 1)
  2.  
  3. displacement k3d_windywave(float Km = 0.1; float txtscale = 1;
  4.                float windfreq = 0.5; float windamp = 1;
  5.                float minwind = 0.3)
  6. {
  7.   float offset;
  8.   point PP;
  9.   float wind;
  10.   float turb, a, i;
  11.  
  12.   PP = txtscale * windfreq * transform("shader", P);
  13.  
  14.   offset = Km * (snoise(PP) + 0.5 * snoise(2 * PP));
  15.  
  16.   turb = 0;
  17.   a = 1;
  18.   PP *= 8;
  19.   for(i = 0; i < 4; i += 1)
  20.     {
  21.       turb += abs(a * snoise(PP));
  22.       PP *= 2;
  23.       a /= 2;
  24.     }
  25.   wind = minwind + windamp * turb;
  26.  
  27. /*  P += wind * offset * normalize(N); */
  28.   N = calculatenormal(P + wind * offset * normalize(N));
  29. }
  30.